/**
 * @file 权限树组件
 * @date 2025/11/15 20:59:22
 * @author lyqjob@yeah.net
 */

import {  useState  } from 'react';
import { Card, Space, Switch, Tree, Typography } from 'antd';

const { Text } = Typography;

const PermissionTree = () => {
    const [treeData] = useState([]);
    const [checkedKeys, setCheckedKeys] = useState([]);
    const [recursiveMode, setRecursiveMode] = useState(true);

    return (
        <Card>
            <Space direction="vertical" style={{ width: '100%' }}>
                <div>
                    <span>递归模式： </span>
                    <Switch 
                        checked={recursiveMode}
                        onChange={setRecursiveMode}
                        checkedChildren="包含子部门"
                        unCheckedChildren="仅当前部门"
                    />
                </div>
                
                <Tree
                    checkable
                    treeData={treeData}
                    checkedKeys={checkedKeys}
                    onCheck={setCheckedKeys}
                    showLine
                    defaultExpandAll
                />
                
                <div>
                    <Text type="secondary">
                        已选择 {checkedKeys.length} 个部门
                        {recursiveMode ? '（包含子部门）' : '（仅当前部门）'}
                    </Text>
                </div>
            </Space>
        </Card>
    );
};

export default PermissionTree;
